using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace 纺织贸易管理系统
{
    public static class JuanHaoTableService
    {
        public static List<JuanHaoTable> GetJuanHaoTablelst(Expression<Func<JuanHaoTable ,bool>> func)
         {
            
            return  Connect.dbcontext.Queryable<JuanHaoTable>().Where (func).ToList ();
         }
        public static JuanHaoTable GetOneJuanHaoTable(Expression<Func<JuanHaoTable, bool>> func)
         {
            return  Connect.dbcontext.Queryable<JuanHaoTable>().First(func)??new JuanHaoTable ();
         }
        public static void InsertJuanHaoTablelst(List<JuanHaoTable> JuanHaoTableObjs)
         {
            Connect.dbcontext.Insertable(JuanHaoTableObjs).ExecuteCommand();
         }
        /// <summary>
        /// 通过库存表获取细码
        /// </summary>
        /// <param name="stock"></param>
        /// <returns></returns>
        public static List<JuanHaoTable> GetJuansWithStock(StockTable stock)
        {
            return Connect.dbcontext.Queryable<JuanHaoTable>().Where (x => x.SampleName == stock.PM && x.GangHao == stock.GH && x.yanse == stock.YS && x.kuanhao == stock.kuanhao && x.CustomerPingMing == stock.LiuzhuanCard && x.state == 0 && x.CustomerName == stock.CustomName&&x.Ckmc==stock.CKMC).OrderBy(x => x.PiHao).ToList();
        }
        public static void InsertJuanHaoTable(JuanHaoTable JuanHaoTableObj)
         {
              Connect.dbcontext.Insertable(JuanHaoTableObj).ExecuteCommand();
         }
        /// <summary>
        /// 批量修改卷号
        /// </summary>
        /// <param name="Setfunc"></param>
        /// <param name="func"></param>
        public static void UpdateJuanHaoTable(string setstr, Expression<Func<JuanHaoTable , bool>> func)
        {
              var ret=Connect.CreatConnect().Update<JuanHaoTable>(setstr, func);
        }
        public static void UpdateJuanHaoTable(Expression<Func<JuanHaoTable, bool>> func,List<JuanHaoTable > juanHaoTables )
        {
            var ret = Connect.CreatConnect().Update<JuanHaoTable>(func, juanHaoTables );
        }
        public static void UpdateJuanHaoTable(JuanHaoTable JuanHaoTableObj, Expression<Func<JuanHaoTable, bool>> func)
         {
              Connect.CreatConnect().Update<JuanHaoTable>(JuanHaoTableObj,func);
         }
        public static void DeleteJuanHaoTable(Expression<Func<JuanHaoTable, bool>> func)
         {
              Connect.dbcontext.Deleteable <JuanHaoTable>(func).ExecuteCommand ();
         }
    }
}
